<?php

class LastFMAPI_Artist extends LastFMAPI {
	
	private $classMethod;
	
	protected function __construct($auth){
		parent::__construct($auth);
		$this->classMethod = "artist.";	
	}
	
	public function getArtistInfo($name){
		$xml = $this->makeRequest($this->classMethod."getinfo",array("artist" => $name,"lang" => "fr", "autocorrect" => "1" ));
		$bioResume = (string)$xml->artist->bio->summary;
		$imgsrc;
		foreach($xml->artist->image as $img) {
    		if ($img["size"]=="large"){
				$imgsrc = (string) $img;
				break;
			}
		}
		
		$html = "";
		if ($imgsrc != null)
			$html .= "<figure class=\"floatleft\"><img src=\"{$imgsrc}\" alt=\"Photo de {$name}\"/></figure>";
			
		if ($bioResume != ""){
			$ligne = explode("\n",$bioResume);
			$l_str = "";
			foreach ($ligne as $l){
				$l_str .= $l."<br/>";	
			}
			$html .="<p>{$l_str}</p>";
			
		}
		else 
			$html ="<p>Aucune information disponible sur {$name}</p>";
		
		return $html; 
		
	}
	
	
	
}

?>